package tcp;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

public class SendByTCP {
    public static void main(String[] args) throws IOException {
        //1.创建Socket对象连接服务器
        Socket socket=new Socket("localhost",12222);
        //2.获取输出流对象
        OutputStream os=socket.getOutputStream();
        os.write("nihao啊".getBytes());
        //3.释放资源
        os.close();
        socket.close();

    }
}
